<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>6.停止定时器</title>
</head>

<body>

    <script>
       window.addEventListener('load', fn1);
        function fn1() {
            var begin = document.querySelector('.start');
            var end = document.querySelector('.stop');
            var timer = null;
            begin.addEventListener('click', function () {
                timer = setInterval(function () {
                    console.log("张勇绝对是个大帅比！");
                },1000);
                
            })
           
            end.addEventListener('click', function () {
                clearInterval(timer);
            })
        }
    </script>
    <button class="start">开启定时器</button>
    <button class="stop">停止定时器</button>


</body>

</html>